#include "stm32f10x.h"                  // Device header
#include "gpio_op.h"
#include "Delay.h"

uint8_t delay = 10;

void Key_init(void) {
	/*开启时钟*/
	//使用各个外设前必须开启时钟，否则对外设的操作无效
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
	
	gpio_init_ipd(GPIOB, GPIO_Pin_0);
}

uint8_t Key_getNum(void) {
	uint8_t num = 0;
	if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 1) {
		Delay_ms(delay);
		while (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) == 1);
		Delay_ms(delay);
		num = 1;
	}
	return num;
}
